#ifndef HOMEWIDGET_H
#define HOMEWIDGET_H

#include <QWidget>
#include<QMap>
#include<QTableWidgetItem>
#include"Global.h"
#include "fileitem.h"
QT_BEGIN_NAMESPACE
namespace Ui { class HomeWidget; }
QT_END_NAMESPACE

class HomeWidget : public QWidget
{
    Q_OBJECT
public:
    HomeWidget(QWidget *parent = nullptr);
    ~HomeWidget();
    void keyPressEvent(QKeyEvent *ev) override;
    void initHttpHandlers();

    void onCancelTask(FileItem* item);

    void showFileList();

    QString getFileType(const QString& filename);

    QString formatFileSizeQt(quint64 bytes, int precision = 1);

private slots:
    void on_MyFilePushButton_clicked();

    void on_UploadPushButton_clicked();

    void onBtFormClick(int id);

    void on_DownloadPushButton_clicked();

    void on_RefreshPushButton_clicked();

signals:

private:
    Ui::HomeWidget *ui;
    QMap<ReqId,std::function<void(const QJsonObject&)>> _handles;
};
#endif // HOMEWIDGET_H
